/*
 * @Description:
 * @Author: Haor
 * @Date: 2022-03-31 09:18:59
 * @LastEditTime: 2022-08-17 21:28:16
 * @LastEditors: 罗梦豪 757986850@qq.com
 */
import { Module } from '@nestjs/common'
import { APP_GUARD } from '@nestjs/core'
import { TypeOrmModule } from '@nestjs/typeorm'
import { AppController } from './app.controller'
import { AppService } from './app.service'
import { UserModule } from './modules/user/user.module'
import { AuthModule } from './modules/auth/auth.module'
import { CommonModule } from './modules/common/common.module'
import { RoleModule } from './modules/role/role.module'
import { DepartmentModule } from './modules/department/department.module';
import { JobModule } from "./modules/job/job.module";
import { CacheModule } from './modules/cache/cache.module';
import { JwtAuthGuard } from '@guards/jwt.auth.guard'
import { ParamSignGuard } from '@guards/sign.guard'
import { PermissionGuard } from "@guards/permission.guard";
import { FileModule } from './modules/file/file.module';
import { MenuModule } from './modules/menu/menu.module';
import { MailModule } from './modules/mail/mail.module';

@Module({
	imports: [
		// typeorm默认使用ormconfig.json这个配置文件。 也可以能过forRoot的参数中确认
        TypeOrmModule.forRoot({
            type: 'mysql',
            host: 'localhost',
            port: 3306,
            username: 'root',
            password: 'root',
            database: 'nest-auth',
            timezone: 'UTC',
            charset: 'utf8mb4',
            entities: ['./**/*.entity.js'],
            synchronize: false,
        }),
		AuthModule,
		CommonModule,
		RoleModule,
		DepartmentModule,
        JobModule,
        CacheModule,
        FileModule,
        MenuModule,
        MailModule
	],
	controllers: [AppController],
	providers: [
		AppService,
		{
			provide: APP_GUARD,
			useClass: ParamSignGuard
		},
        {
            provide: APP_GUARD,
            useClass: PermissionGuard
        },
        {
            provide: APP_GUARD,
            useClass: JwtAuthGuard
        }
	]
})
export class AppModule {}
